<template>
  <page-header-wrapper>
    <a-card :bordered="false" class="card_top_padding no_need_padding" style="padding-bottom: 20px">
      <div v-loading="loading">
        <a-alert message="此配置用于自动识别营业执照和身份证" type="info" show-icon style="margin: 10px 0 20px 15px" />
        <a-form-model ref="wechatForm" :model="form" :labelCol="{ span: 3 }" :wrapperCol="{ span: 12 }">
          <a-form-model-item label="appkey">
            <a-input v-model="form.app_key" type="text" />
          </a-form-model-item>
          <a-form-model-item label="AppSecret">
            <a-input v-model="form.app_secret" type="text" />
          </a-form-model-item>
          <!-- <a-form-model-item label="购买地址">
            <a-input disabled value="https://www.aliyun.com/search?scene=all&k=ocr" type="text" />
          </a-form-model-item> -->
          <a-form-model-item :wrapper-col="{ span: 24 }">
            <a-divider style="margin: 0 0 40px 0" />
            <div style="display: flex; justify-content: center">
              <a-button :loading="btnLoading" type="primary" @click="submitForm" style="margin-right: 8px"> 保存 </a-button>
              <a-button @click="$router.back()"> 取消 </a-button>
            </div>
          </a-form-model-item>
        </a-form-model>
      </div>
    </a-card>
  </page-header-wrapper>
</template>
<script>
import { orcSub, ocrInfo } from '@/api/saas/setting'
export default {
  name: 'SaasSettingAgency',
  data() {
    return {
      form: {
        appkey: '',
        app_secret: '',
      },
      btnLoading: false,
    }
  },
  created() {
    this.getData()
  },
  methods: {
    async getData() {
      const res = await ocrInfo()
      if (res.code == 0) {
        console.log(res)
        this.form = res.data
      }
    },
    async submitForm() {
      this.btnLoading = true
      const res = await orcSub({ content: this.form })
      if (res.code == 0) {
        this.$message.success('保存成功')
      } else {
        this.$message.error(res.msg)
      }
      this.btnLoading = false
    },
  },
}
</script>
